<% content_for :stylesheet_head do %>
<style>
    /*  .table {
        box-shadow: 0 0;
    }*/
  .bu,button.button,tr td button {
        padding: 2px 10px;
        margin: 0px 10px;
        background: #009bce;
        border-radius: 4px;
        border: 1px;
        color: #fff;
    }
  #pass_no,#card_sn{
      background: #799a96;
  }
  #treeDemo_new{
        width: 340px;display: none;position: absolute;background: #fff;
    }
  #treeDemo_new2{
        width: 340px;display: none;position: absolute;background: #fff;
    }
 tr.focus{
      background-color:rgb(238, 238, 238);
  }
</style>
<% end %>

<!-- 隐藏框 -->
<div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<h4 class="modal-title" id="ModalLabel">人员信息:</h4>
  <table class="table list_table">
    <tr>
      <td>卡号</td>
      <td>人员编号</td>
      <td>姓名</td>
      <td>部门</td>
      <td>职务</td>
      <td>时间</td>
    </tr>
    <tbody  id="tr_person">        
    </tbody>
  </table>
<h4 class="modal-title" id="ModalLabel">钱箱信息:</h4>
  <table class="table list_table">
    <tr>
    <td>卡号</td>
    <td>编号</td>
    <td>网点</td>
    <td>时间</td>
    </tr>
    <tbody id="tr_box">
    </tbody>
  </table>
</div>
<div class="modal-footer">
  <button type="reset" class="btn btn-default" data-dismiss="modal">
               关闭
  </button>
</div>
</div>
</div>
</div>
<!-- 隐藏框 -->
<div class="listFilter" style="margin: 20px;">
<h2>流水查询</h2>
<div class="bu" data-toggle="modal" data-target="#Modal"  style="min-width: 100px;text-align: center;float: right;cursor: pointer;display:none;">
</div>
<div class="divider"></div>
<%= form_for_filterrific @filterrific do |f| %>
    <table style="width: 100%;" class="list_table">
          <tbody>
            <tr>
              <td>开始时间:</td>
              <td><%= f.text_field :with_begin_time,onclick:"SelectDate(this,'yyyy-MM-dd hh:mm:ss')"%></td>
              <td>结束时间:</td>
              <td><%= f.text_field :with_end_time,onclick: "SelectDate(this,'yyyy-MM-dd hh:mm:ss')" %></td>
              <td><%= f.submit "查询", :class=>"button" %></td>
            </tr>
          </tbody>
    </table>
<% end %>
<div class="list_table" id="ltReport_list">
<table class="list_table" id="ltReport_list" width="100%" cellspacing="0" style="text-align: left;">
  <thead>
    <tr>
      <th>序号</th>
      <th>收发状态</th>
      <th>记录编号</th>
      <th>主交接人</th>
      <th>副交接人</th>
      <th>交接网点</th>
      <th>交接时间</th>
    </tr>
  </thead>
  <tbody id="tbody">
  <%  if @class_record != nil
     odd_or_even = 0
     tmp=0
    @class_record.each do |class_record|
       tmp = tmp+1
  -%>
          <tr class="odd_row" onclick="aaa('<%= class_record.record_id %>' );" >
              <td><%= h(tmp) %></td>
              <td><%= class_record.flag %></td>
              <td><%= class_record.record_id %></td>
              <td><%= class_record.main_turn %></td>
              <td><%= class_record.common_turn %></td>
              <td><%= class_record.net_address %></td>
              <td><%= class_record.created_at.strftime("%Y-%m-%d %H:%M:%S")%></td>
         </tr>
    <% end %>
    <% end %>
  <tr>
    <td colspan="7">
         <%= will_paginate(@class_record ,:previous_label=>'上一页',:next_label=>'下一页')  %>
    </td>
 </tr>
  </tbody>
</table>
<div class="WhereToLinks"></div>
</div>
</div>
<% content_for :javascript_fool do %>
    <script>
      function aaa(id){ 
        var url="/report/ajax_function?a="+id;
        $.ajax({url:url,
                async:false,
                type: "get",
                success:function(r){
                    abc=eval("("+r+")");
                    person=abc.a;
                    box=abc.b;
                    var tr_person=document.getElementById("tr_person");
                    var tr_box=document.getElementById("tr_box")
                    tr_person.innerHTML="";
                    for(var i=0 ; i<person.length;i++){
                       console.log(typeof(person[i].created_at));
                       var tr_dom=document.createElement("tr");
                       var td_created_at=document.createElement("td");
                       td_created_at.innerHTML=person[i].created_at;
                       $(tr_dom).prepend(td_created_at);
                       var td_post=document.createElement("td");
                       td_post.innerHTML=person[i].post ;
                       $(tr_dom).prepend(td_post);
                       var td_section=document.createElement("td");
                       td_section.innerHTML=person[i].section ;
                       $(tr_dom).prepend(td_section);
                       var td_name=document.createElement("td");
                       td_name.innerHTML=person[i].name ;
                       $(tr_dom).prepend(td_name);
                       var td_pass_no=document.createElement("td");
                       td_pass_no.innerHTML=person[i].pass_no ;
                       $(tr_dom).prepend(td_pass_no);
                       var td_card_sn=document.createElement("td");
                       td_card_sn.innerHTML=person[i].card_sn ;
                       $(tr_dom).prepend(td_card_sn);                                        
                       $(tr_person).prepend(tr_dom);
                    }  
                    tr_box.innerHTML=""; 
                    for(var i=0 ; i<box.length;i++){
                       var tr_dom=document.createElement("tr");
                       var td_created_at=document.createElement("td");
                       td_created_at.innerHTML=box[i].created_at;
                       $(tr_dom).prepend(td_created_at);
                       var td_net_address=document.createElement("td");
                       td_net_address.innerHTML=box[i].net_address ;
                       $(tr_dom).prepend(td_net_address);
                       var td_pass_no=document.createElement("td");
                       td_pass_no.innerHTML=box[i].pass_no ;
                       $(tr_dom).prepend(td_pass_no);
                       var td_card_sn=document.createElement("td");
                       td_card_sn.innerHTML=box[i].card_sn ;
                       $(tr_dom).prepend(td_card_sn);                                     
                       $(tr_box).prepend(tr_dom);
                    }  
                                   }
             })
      }


      var trs = document.getElementById('tbody').getElementsByTagName('tr');  
      window.onload = function(){  
       for( var i=0; i<trs.length; i++ ){  
        trs[i].onmousedown = function(){  
         tronmousedown(this);
         $('.bu')[0].click();  
        }  
       }  
      }  
      function tronmousedown(obj){  
       for( var o=0; o<trs.length; o++ ){  
        if( trs[o] == obj ){  
         trs[o].style.backgroundColor = '#009bce';  
        }  
        else{  
         trs[o].style.backgroundColor = '';  
        }  
       }  
      }  


    </script>
<% end %>
